package com.vf.admin.miaodong.controller;

import cn.hutool.core.util.ObjectUtil;
import com.vf.admin.client.common.RedisKeys;
import com.vf.admin.common.BaseController;
import com.vf.admin.common.redis.RedisUtil;
import com.vf.admin.miaodong.entity.AppActive;
import com.vf.admin.miaodong.service.AfterAppActiveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Date;
import java.util.Set;

/**
 * <p>Title : </p>
 * <p>Description : </p>
 * <p>DevelopTools : IDEA</p>
 * <p>DevelopSystem : Windows11</p>
 *
 * @Author : zxw
 * @Date 2023/8/11 10:35
 */
@Controller
@RequestMapping("/after/active")
public class AfterAppActiveController extends BaseController {


    @Autowired
    private AfterAppActiveService afterAppActiveService;
    @Autowired
    RedisUtil redisUtil;


    /**
     * 保存日活数据
     */
    @RequestMapping("/add")
    public void add(){

        Set<String> keys = redisUtil.keys(RedisKeys.active + "*");
        System.out.println("日活跃度" + keys.size());
        AppActive appActive = new AppActive();
        appActive.setNum(ObjectUtil.isNotNull(keys.size()) ? keys.size() : 0);
        appActive.setCreatetime(new Date());
        afterAppActiveService.saveAppActiveNumCount(appActive);
    }
}
